import { RootThunkAction } from '../index';

export type TodoAction =
  | {
    type: 'ADD_TODO'
    name: string
  }
  | {
    type: 'DEL_TODO'
    id: number
  }
  | {
    type: 'asd'
    m: 'ss'
  }

export function addTodo(name: string): TodoAction {
  return {
    type: 'ADD_TODO',
    name
  }
}

export function delTodo(id: number): RootThunkAction {
  return (dispatch, getState) => {
    setTimeout(() => {
      dispatch({
        type: "DEL_TODO",
        id
      })
    }, 1000)
  }
}